names = ['zhang','lisi','xiaoming','zhao','liu'] 
scores = [95,88,99,90,95,10]  

students={}
for i in range(0,len(names)):
    students[names[i]]=scores[i]

print(students) 
print(students['liu']) 

#zip() - 拉链
z = zip(names,scores)
stu = dict(z)  
print(stu) 


#copy() - 拷贝
stu2 = stu.copy()  #创建新的字典
# stu2 = stu   # 不创建新的字典
print(stu,id(stu)) 
print(stu2,id(stu2)) 

#hash() -  哈希函数
# print(hash('zhang'))  
# print(hash('zhang'))  
# print(hash('lisi'))  


# stu3={}
# stu4 = stu3.fromkeys(names)   #创建一个新的字典并返回  把names中的元素作为键
# print(stu4)
# print(stu3.fromkeys(names,0))  #指定键对应的值，如果不指定，默认值是None

#items() - 返回dict_items
its = stu2.items()
print(its,type(its))  
its = list(its)   #[('zhang', 95), ('lisi', 88), ('xiaoming', 99), ('zhao', 90), ('liu', 95)]
it =its[0]     #('zhang', 95)
print(it[0],it[1])   

# in  - 检查字典中是否有给定的键
print('zhou' in stu2)   #False
print('lisi' in stu2)   #True

#len(dict) - 返回字典中键的数量
print(len(stu2))   # 一个键值对算一个
 


 

